#include<iostream>
using namespace std;

int main()          //药房统计，很可以
{
    int m;
    cin >> m;
    int n;
    cin >> n;
    int medicine = 0;
    int sum = 0;
    int count = 0;
    for(int i = 0;i<n;i++)
    {
        cin >> medicine ;
        sum = medicine +sum;
        if(sum<=m)
        {
            count++;
        }
        else
        {
            sum = sum-medicine;
            continue;
        }
    }
    cout << n-count << endl;
    return 0;
}